package initialization;

public class Exercise12 {

	public static void main(String[] args) {
		Tank t1 = new Tank();
		Tank t2 = new Tank();
		Tank t3 = new Tank();
		new Tank();
		t1.fill();
		t2.fill();
		t2.empty();
		t1 = null;
		t2 = null;
		t3 = null;
		System.gc();
	}
}

class Tank {

	private static int counter = 0;
	private boolean isEmpty = true;
	private int id = counter++;
	
	public void fill() {
		this.isEmpty = false;
	}

	public void empty() {
		this.isEmpty = true;
	}

	protected void finalize() {
		if (!isEmpty)
			System.out.println("Error: Tank" + this.id + " is not empty");
		else
			System.out.println("tank" + this.id + " is emptye and removed");
		// super.finalize();
	}
}
